# Contributor: Andy Li <andy@onthewings.net>
# Maintainer: Andy Li <andy@onthewings.net>
pkgname=ocaml-sha
pkgver=1.12
pkgrel=0
pkgdesc="Binding to the SHA cryptographic functions"
url="https://github.com/djs55/ocaml-sha"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml aport
license="ISC"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune ocaml ocaml-findlib ocaml-ounit-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"

build() {
	dune build @install -p sha --no-buffer --verbose
}

check() {
	dune runtest --verbose
}

package() {
	mkdir -p "$pkgdir"/usr/lib/ocaml
	dune install --destdir="$pkgdir"

	# There are just CHANGES, README, and LICENSE.
	rm -Rf "$pkgdir"/usr/doc

	# Remove annotation files and sources.
	rm \
		"$pkgdir"/usr/lib/ocaml/sha/*.cmt \
		"$pkgdir"/usr/lib/ocaml/sha/*.cmti \
		"$pkgdir"/usr/lib/ocaml/sha/*.ml
}

dev() {
	default_dev

	mkdir -p "$subpkgdir"/usr/lib/ocaml/sha
	mv \
		"$pkgdir"/usr/lib/ocaml/sha/*.cmx \
		"$pkgdir"/usr/lib/ocaml/sha/*.cmxa \
		"$pkgdir"/usr/lib/ocaml/sha/*.mli \
		"$subpkgdir"/usr/lib/ocaml/sha/
}

sha512sums="e6cdbc66202281a72ccc3592d6efba0448fe28dba7a23f8079d3a3cee12c03d01338191da88e4e4834f5ee19321ffed1c950e7a5babc73479221d8da3fe372d3  ocaml-sha-1.12.tar.gz"
